﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TP01
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void quitteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            if (System.IO.File.Exists(openFileDialog1.FileName))
            {
                this.richTextBox1.Text = System.IO.File.ReadAllText(openFileDialog1.FileName);
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void ouvrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
        }

        private void corrigerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string[] words = richTextBox1.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            LinkedList<string> List = new LinkedList<string>(words);
            if (List.First == null)
                return;
            TP.Correct.Plural(List.First);
            TP.Correct.WordWithApp(List.First);
            TP.Correct.CheckDictionary(List.First);
            string output = "";
            foreach (string word in List)
            { output += word + " "; }
            richTextBox1.Text = output;
        }

        private void richTextBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void plurielToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string[] words = richTextBox1.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            LinkedList<string> List = new LinkedList<string>(words);
            if (List.First == null)
                return;
            TP.Correct.Plural(List.First);
            string output = "";
            foreach (string word in List)
            { output += word + " "; }
            richTextBox1.Text = output;
        }

        private void motsEnAppToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string[] words = richTextBox1.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            LinkedList<string> List = new LinkedList<string>(words);
            if (List.First == null)
                return;
            TP.Correct.WordWithApp(List.First);
            string output = "";
            foreach (string word in List)
            { output += word + " "; }
            richTextBox1.Text = output;
        }

        private void conjugueToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string[] words = richTextBox1.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            LinkedList<string> List = new LinkedList<string>(words);
            if (List.First == null)
                return;
           
            string output = "";
            foreach (string word in List)
            {
                foreach (string verb in TP.Conjugate.ConjugateVerb(word))
                {
                    output += verb + " ";
                }
                output += "\n";
            }
            richTextBox1.Text = output;
        }

        private void conjugueAvecPronomToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string[] words = richTextBox1.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            LinkedList<string> List = new LinkedList<string>(words);
            if (List.First == null)
                return;
            string output = "";
            string pronoun = "";
            foreach (string word in List)
            {
                if (pronoun == "")
                { pronoun = word; }
                else
                {
                    output += pronoun + " " + TP.Conjugate.ConjugatePronoun(pronoun, word);
                    output += "\n";
                    pronoun = "";
                }
            }
            richTextBox1.Text = output;
        }

        private void maPremiereVariableToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = TP.Basic.MyFirstVariable();
        }

        private void conjugaisonToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void punitionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = TP.Basic.Punition(100);
        }

        private void punition2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = TP.Basic.Punition2(100);
        }

        private void dictionaireToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string[] words = richTextBox1.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            LinkedList<string> List = new LinkedList<string>(words);
            if (List.First == null)
                return;
            TP.Correct.Plural(List.First);
            string output = "";
            foreach (string word in List)
            { output += word + " "; }
            richTextBox1.Text = output;
        }
    }
}
